package logic

import (
	"cart_srv/cart"
	"context"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartClearLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewCartClearLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartClearLogic {
	return &CartClearLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *CartClearLogic) CartClear(req *types.CartClearRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	userId := 1
	cartClear, err := l.svcCtx.CartRpc.CartClear(l.ctx, &cart.CartClearRequest{UserId: int64(userId)})
	if err != nil {
		return &types.Response{
			Msg:  err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}
	return &types.Response{
		Msg:  "清空成功",
		Code: 200,
		Data: cartClear,
	}, nil
}
